import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
public class Main201521123073 { 
    public static void main(String[] args) {
    	Scanner in=new Scanner(System.in);
    	Map<String,Integer> words = new HashMap<String,Integer>();	 
        while(in.hasNextLine()){
        	String str=in.next();
        	Integer count=words.get(str);
        	if(str.equals("!!!!!")){
        		break;
        	}
        	else 
        	  if(count==null){
        		  words.put(str,1);
        	  }
        	  else{
        		  words.put(str, ++count);
        	  }  			 
        }      
      List<Entry<String,Integer>> list=new ArrayList<Entry<String,Integer>>();
      for(Entry<String,Integer> e:words.entrySet()){
    	  list.add(e);
      }
      Collections.sort(list,new Comparator<Entry<String,Integer>>(){
		public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
			 if((o1.getValue().compareTo(o2.getValue()))==0){
				 return o1.getKey().compareTo(o2.getKey());
			 }
			  return -o1.getValue().compareTo(o2.getValue());
		}  
      });
      System.out.println(list.size());
      for(int i=0;i<10;i++){
    	  System.out.println(list.get(i));
      }  
    }  
}